<template>
  <div class="grid_cont">
    <div style="display: flex">
      <div style="width: 3px; height: 18px; background-color: rgba(204, 53, 47, 1)"></div>
      <div style="margin-left: 10px; font-size: 16px; line-height: 16px">详情</div>
    </div>
    <div
      style="
        width: 100%;
        height: 1px;
        background-color: rgba(245, 245, 245, 1);
        margin-top: 16px;
        margin-bottom: 30px;
      "
    >
    </div>
    <el-form
      :model="formParams"
      ref="formRef"
      style="margin-left: 14px; text-align: right"
      label-width="126px"
    >
      <el-form-item  label="新增类型：" prop="carouselImageType">
        <el-input
          v-model="formParams.carouselImageType"
          placeholder=""
          placement="bottom"
          style="width: 588px"
          disabled
        />
      </el-form-item>
      <el-form-item  label="标题：" prop="topic">
        <el-input disabled v-model="formParams.topic" style="max-width: 588px" />
      </el-form-item>
      <el-form-item  label="图片：" prop="attachmentUrl">
        <UploadImg disabled v-model="formParams.attachmentUrl" :limit="1" />
      </el-form-item>
      <el-form-item  label="跳转到内容：" prop="contentType">
        <el-button disabled :class="{ editBtn: showEdit }">自主编辑</el-button>
        <el-button disabled :class="{ editBtn: showLink }">外部链接</el-button>
      </el-form-item>
      <el-form-item v-if="showLink"  label="链接地址：" prop="linkAddr">
        <el-input disabled v-model="formParams.linkAddr" style="max-width: 588px" />
      </el-form-item>
      <el-form-item v-if="showEdit" label="文章来源：" prop="contentSource">
        <el-input disabled v-model="formParams.contentSource" style="max-width: 588px" />
      </el-form-item>
      <el-form-item  v-if="showEdit" label="活动介绍：" prop="content">
        <div style="max-width: 586px; text-align: left">
          <div class="introducestyle">
            <Editor
              v-model="formParams.content"
              style="max-width: 586px; cursor: not-allowed"
              :editor-config="editorConfig"
            />
          </div>
        </div>
      </el-form-item>
    </el-form>
  </div>
  <div class="grid_cont2">
    <el-button class="grid_btn" @click="detailsbtn">返回</el-button>
  </div>
</template>

<script lang="ts" setup>
import * as getSwiperApi from '@/api/appManagement/swiperManagement/index'
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import type { UploadProps } from 'element-plus'
const { push } = useRouter() // 路由
const route = useRoute()
const editorConfig = ref({
  MENU_CONF: {},
  readOnly: readonly
})
const formParams = reactive({
  topic: '',
  attachmentUrl: '',
  contentType: '',
  contentSource: '',
  content: '',
  carouselImageType: '',
  linkAddr:''
})
const formRef = ref() // 搜索的表单

/** 返回 */
const detailsbtn = () => {
  push({
    name: 'swiperManagement'
  })
}
const showEdit = ref(true)
const showLink = ref(false)
const getData = () => {
  getSwiperApi.getSwiperDetail(route.query.id).then((res) => {
    formParams.topic = res.topic
    formParams.attachmentUrl = res.attachmentUrl
    formParams.contentType = res.contentType
    formParams.content = res.content
    formParams.contentSource = res.contentSource
    formParams.carouselImageType = res.carouselImageType
    formParams.linkAddr = res.linkAddr
    if (res.contentType === '自主编辑') {
      showEdit.value = true
      showLink.value = false
    } else {
      showEdit.value = false
      showLink.value = true
    }
  })
}
onMounted(() => {
  getData()
})
</script>
<style scoped>
.grid_cont {
  min-height: 600px;
  background: #fff;
  padding: 16px;
}

.grid_cont2 {
  width: 100%;
  background: #fff;
  padding: 16px;
  height: 65px;
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 0;
  box-shadow: 0px -2px 6px 0px rgba(188, 188, 188, 0.65);
}

.grid_btn {
  width: 80px;
  height: 30px;
  background-color: #ff9900;
  border: none;
  color: #fff;
}

.grid_btn:hover {
  opacity: 0.8;
}

::v-deep .avatar-uploader .el-upload {
  border: 1px solid var(--el-border-color);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
  cursor: not-allowed;
}

::v-deep .el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 150px;
  height: 150px;
  text-align: center;
  cursor: not-allowed;
  background-color: var(--el-disabled-bg-color);
}

::v-deep .el-cascader .el-input.is-focus .el-input__wrapper {
  box-shadow: 0 0 0 1px #cc352f !important;
}

.introducestyle {
  box-shadow: 0 0 0 1px var(--el-disabled-border-color);
  border-radius: 4px;
  background: var(--el-disabled-bg-color) !important;
}

.introducestyle::selection {
  box-shadow: 0 0 0 1px #cc352f !important;
}

::v-deep .w-e-text-placeholder {
  top: 10px;
  text-align: justify;
  width: 96%;
}

::v-deep .w-e-bar {
  background: transparent !important;
}

::v-deep .w-e-text-container {
  background: transparent !important;
}

::v-deep .w-e-bar {
  box-shadow: 0px 1px 0px 0px var(--el-disabled-border-color);
  pointer-events: none;
  cursor: not-allowed;
  background: var(--el-disabled-bg-color) !important;
}

::v-deep .border-solid {
  border-color: var(--el-disabled-bg-color);
  border-radius: 4px;
}

:deep(.w-e-text-container [data-slate-editor] img) {
  cursor: not-allowed !important;
}

:deep(.w-e-text-container [data-slate-editor]) {
  background: var(--el-disabled-bg-color) !important;
}
.el-button {
  width: 80px;
  height: 30px;
}
.editBtn:hover {
  width: 80px;
  height: 30px;
  color: #fff;
  background: #ea4f11;
  border: 0;
}
.editBtn {
  color: #fff;
  background: #ea4f11;
  border: 0;
}
:deep(.w-e-text-container [data-slate-editor] p){
  color:#a8abb2;
}
</style>
